//
//  ActivityTypeself.m
//  ExcellentHome
//
//  Created by 揭婧雯 on 16/9/2.
//  Copyright © 2016年 陈区. All rights reserved.
//

#import "ActivityTypeCell.h"
//#import "Masonry.h"

@interface ActivityTypeCell ()

@property (nonatomic, strong) UILabel* typeNameLabel;
@property (nonatomic, strong) UILabel* typeCountLabel;

@end


@implementation ActivityTypeCell

+ (instancetype)cellWithTableView:(UITableView*)tableView
{
    ActivityTypeCell* cell = [tableView dequeueReusableCellWithIdentifier:kActivityTypeCellIdentifier];
    
    if (cell == nil) {
        
        cell = [[ActivityTypeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kActivityTypeCellIdentifier];
    }
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier
{
    
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    return self;
}

- (void)setFrame:(CGRect)frame
{
    frame.size.width = [UIScreen mainScreen].bounds.size.width;
    [super setFrame:frame];
}

- (void)setupUI
{
    self.accessoryType = UITableViewCellAccessoryNone;
    self.selectionStyle = UITableViewCellSelectionStyleNone;

    // 顶部线条
    UIImageView *linebg1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds), 0.5)];
    linebg1.image = [UIImage imageWithContentsOfFile:SEGPicName(@"common_line610px.png")];
    linebg1.backgroundColor = [UIColor yellowColor];
    linebg1.contentMode = UIViewContentModeScaleToFill;
    [self.contentView addSubview:linebg1];
    
    UIImageView *linebg2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 39.5, CGRectGetWidth(self.bounds), 0.5)];
    linebg2.image = [UIImage imageWithContentsOfFile:SEGPicName(@"common_line610px.png")];
    linebg2.contentMode = UIViewContentModeScaleToFill;
    linebg2.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:linebg2];
    
    self.typeNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 80, 40)];
    self.typeNameLabel.font = [UIFont systemFontOfSize:13];
    self.typeNameLabel.backgroundColor = [UIColor clearColor];
    self.typeNameLabel.textColor=kColor_1;
    [self.contentView addSubview:self.typeNameLabel];
    
    self.typeCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetWidth(self.bounds)-40-40, 0, 40, 40)];
    self.typeCountLabel.font = [UIFont systemFontOfSize:FONT_DESCRIPTION_SIZE];
    self.typeCountLabel.backgroundColor = [UIColor clearColor];
    self.typeCountLabel.textColor=kColor_3;
    [self.contentView addSubview:self.typeCountLabel];
    
    //右边箭头
    UIImageView *arrow = [[UIImageView alloc] init];
    arrow.image = [UIImage imageWithContentsOfFile:SEGPicName(@"btn_more_gray")];
    arrow.frame=CGRectMake(CGRectGetWidth(self.bounds)-arrow.image.size.width-20, (40-arrow.image.size.height)/2, arrow.image.size.width, arrow.image.size.height);
    [self.contentView addSubview:arrow];
}

- (void)setTypeName:(NSString *)name
{
    self.typeNameLabel.text= name;
}
- (void)setTypeCount:(NSInteger)count
{
    self.typeCountLabel.text= [NSString stringWithFormat:@"%lu个",(unsigned long)count];
}
@end
